-- --------------------------------------------------------
---  create table ---
-- #Table: sys_actor

-- DROP TABLE sys_actor;

CREATE TABLE sys_actor
(
  id_sys_actor varchar(40) NOT NULL,
  code varchar(50),
  "name" varchar(100),
  flag_type smallint,
  flag_disabled smallint,
  flag_deleted smallint,
  remark longvarchar,
  created_date date,
  created_userid varchar(40),
  updated_date date,
  updated_userid varchar(40),
  owned_userid varchar(40),  
  CONSTRAINT sys_actor_pk PRIMARY KEY (id_sys_actor)
);

-- #Table: sys_user

-- DROP TABLE sys_user;
CREATE TABLE sys_user
(
  id_sys_actor varchar(40) NOT NULL,
  password varchar(100),
  email varchar(100),
  qq varchar(100),
  mobilephone varchar(100),
  officephone varchar(100),
  expired_date date,
  CONSTRAINT sys_user_pk PRIMARY KEY (id_sys_actor)
);

-- #Table: sys_role

-- DROP TABLE sys_role;
CREATE TABLE sys_role
(
  id_sys_role varchar(40) NOT NULL,
  code varchar(50),
  name varchar(100),
  flag_disabled smallint,
  flag_deleted smallint,
  remark longvarchar,
  role varchar(50) NOT NULL,
  treemap longvarchar,
  created_date date,
  created_userid varchar(40),
  updated_date date,
  updated_userid varchar(40),
  owned_userid varchar(40),  
  CONSTRAINT sys_role_pk PRIMARY KEY (id_sys_role)
);

-- #Table: sys_resource

-- DROP TABLE sys_resource;

CREATE TABLE sys_resource
(
  id_sys_resource varchar(40) NOT NULL,
  code varchar(100),
  module_id varchar(200),
  remark longvarchar,
  flag_deleted smallint,
  flag_disabled smallint,
  classname varchar(200),
  locked smallint,	
  created_date date,
  created_userid varchar(40),
  updated_date date,
  updated_userid varchar(40),
  owned_userid varchar(40),  
  CONSTRAINT sys_resource_pk PRIMARY KEY (id_sys_resource)
);


CREATE TABLE sys_menu_resource
(
  id_resource varchar(40) NOT NULL,
  menu_level smallint NOT NULL ,
  parent_id varchar(40),
  function_id varchar(40),
  name varchar(200),
  flag_disabled smallint NOT NULL,
  act varchar(100),
  tree_map longvarchar,
  CONSTRAINT sys_menu_resource_pk PRIMARY KEY (id_resource)
);


-- #Table: sys_module_function_resource

-- DROP TABLE sys_module_function_resource;
CREATE TABLE sys_module_function_resource
(
  id_resource varchar(40) NOT NULL,
  name varchar(100),
  id_sys_module varchar(40) NOT NULL,
  CONSTRAINT sys_module_function_resource_pk PRIMARY KEY (id_resource)
);


-- #Table: sys_module_resource

-- DROP TABLE sys_module_resource;

CREATE TABLE sys_module_resource
(
  id_resource varchar(40) NOT NULL,
  "name" varchar(200),
  "version" varchar(100),
  developer varchar(100),
  release_date date,
  group_id varchar,
  CONSTRAINT sys_module_resource_pk PRIMARY KEY (id_resource)
);

-- #Table: sys_url_resource

-- DROP TABLE sys_url_resource;
CREATE TABLE sys_url_resource
(
  id_resource varchar(40) NOT NULL,
  link varchar(200),
  function_id varchar(40),
  type varchar(50),
  CONSTRAINT sys_url_resource_pk PRIMARY KEY (id_resource)
);



-- #Table: sys_permission

-- DROP TABLE sys_permission;

CREATE TABLE sys_permission
(
  id_sys_permission varchar(40) NOT NULL,
  id_sys_role varchar(40) NOT NULL,
  id_sys_resource varchar(40) NOT NULL,
  access_control varchar(200) NOT NULL,
  auth_started_date date,
  auth_end_date date,
  CONSTRAINT sys_permission_pk PRIMARY KEY (id_sys_role, id_sys_resource)
);


-- #Table: sys_binding_action

-- DROP TABLE sys_binding_action;
CREATE TABLE sys_binding_action
(
  id_sys_binding_action varchar(40) NOT NULL,
  id_resource varchar(40) NOT NULL,
  "action" varchar(200) NOT NULL,
  CONSTRAINT sys_binding_action_pk PRIMARY KEY (id_sys_binding_action)
);


-- #Table: map_actor_role

-- DROP TABLE map_actor_role;

CREATE TABLE map_actor_role
(
  id_sys_actor varchar(40) NOT NULL,
  id_sys_role varchar(40) NOT NULL,
  CONSTRAINT map_actor_role_pk PRIMARY KEY (id_sys_actor, id_sys_role)
);



-- #Table: map_role_hierarchy

-- DROP TABLE map_role_hierarchy;

CREATE TABLE map_role_hierarchy
(
  id_role_inheritance varchar(40) NOT NULL,
  id_role_dependence varchar(40) NOT NULL,
  CONSTRAINT map_role_hierarchy_pk PRIMARY KEY (id_role_inheritance, id_role_dependence)
);

